package com.amos.think.service;

import com.alibaba.cola.catchlog.CatchAndLog;
import com.amos.think.api.IUserMongoService;
//import com.amos.think.domain.gateway.UserMongoGateway;
import com.amos.think.dto.UserRegisterCmd;
import com.amos.think.dto.data.UserVO;
import com.amos.think.service.mq.MessageService;
import com.amos.think.service.mq.RocketMQProducer;
import com.amos.think.user.command.query.UserMongoQueryExe;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户相关
 */
@Service
@CatchAndLog
@Slf4j
public class UserMongoServiceImpl implements IUserMongoService {

    /**
     * xxxExe 避免 Service 膨胀利器
     */


    @Autowired
    private UserMongoQueryExe userMongoQueryExe;


//    @Autowired
//    private RocketMQProducer rocketMQProducer;
    @Autowired
    private MessageService messageService;

    @Override
    public void register(UserRegisterCmd cmd)  {
        try {
            userMongoQueryExe.execute(cmd);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    @Override
    public List<UserVO> getAllUsers() {
        return userMongoQueryExe.executeAllUser();
    }

    @Override
    public void updateUserInfo(UserRegisterCmd userRegisterCmd) {
        userMongoQueryExe.executeUpdate(userRegisterCmd);
    }

    @Override
    public void delete(String userId) {
        userMongoQueryExe.executeDelete(userId);
    }


}
